home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 123 / cdrom123.iso / essenc / extens / imzoom / Image Zoom.xpi / chrome / imagezoom.jar / content / dialogs.js < prev    next >
Encoding:
JavaScript  |  2004-07-05  |  3.4 KB  |  128 lines

  1. /* ***** BEGIN LICENSE BLOCK *****
  2.  
  3.     Copyright (c) 2004  Jason Adams <jason_nospam@yellowgorilla.net>
  4.  
  5.     This file is part of Image Zoom.
  6.  
  7.     Image Zoom is free software; you can redistribute it and/or modify
  8.     it under the terms of the GNU General Public License as published by
  9.     the Free Software Foundation; either version 2 of the License, or
  10.     (at your option) any later version.
  11.  
  12.     Image Zoom is distributed in the hope that it will be useful,
  13.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.     GNU General Public License for more details.
  16.  
  17.     You should have received a copy of the GNU General Public License
  18.     along with Image Zoom; if not, write to the Free Software
  19.     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  20.  
  21.  * ***** END LICENSE BLOCK ***** */
  22.  
  23. var gDimRatio = 0.0;
  24. var gDimWidth;
  25. var gDimHeight;
  26. var gDimAspect;
  27.  
  28. function validateKeyPress(e){
  29.     switch(e.which) {
  30.        case 0:  //misc
  31.        case 8: //backspace
  32.            return true;
  33.            break
  34.        default:
  35.                var key = String.fromCharCode(e.which);
  36.             if(pIsNumeric(key)){
  37.                 return true;
  38.             } else {
  39.                 return false;
  40.             }
  41.     }
  42. }
  43.  
  44. function widthPress(e)
  45. {
  46.     switch(e.which) {
  47.        case 0:  //misc
  48.        case 8: //backspace
  49.        case 46: //delete
  50.            return true;
  51.            break
  52.        default:
  53.                var key = String.fromCharCode(e.which);
  54.             if(pIsNumeric(key) && key != "."){
  55.                 return true;
  56.             } else {
  57.                 return false;
  58.             }
  59.     }
  60. }
  61.  
  62. function widthInput(e){
  63.     if (gDimAspect.checked) {
  64.         if (pIsNumeric(gDimWidth.value) && (gDimWidth.value != "")){
  65.             gDimHeight.value = parseInt((parseInt(gDimWidth.value)/gDimRatio)+0.5);
  66.         } else {
  67.             gDimHeight.value = "";
  68.         }
  69.     }
  70. }
  71.  
  72. function heightInput(e){
  73.     if (gDimAspect.checked) {
  74.         if (pIsNumeric(gDimHeight.value) && gDimHeight.value != ""){
  75.             gDimWidth.value = parseInt((parseInt(gDimHeight.value)*gDimRatio)+0.5);
  76.         } else {
  77.             gDimWidth.value = "";
  78.         }
  79.     }
  80. }
  81.  
  82. function checkInput(e){
  83.     if (!gDimAspect.checked) {
  84.         if (pIsNumeric(gDimWidth.value) && gDimWidth.value != ""){
  85.             gDimHeight.value = parseInt((parseInt(gDimWidth.value)/gDimRatio)+0.5);
  86.         } else {
  87.             gDimHeight.value = "";
  88.         }
  89.     }
  90. }
  91.  
  92. function imagezoom_customZoom()
  93. {
  94.     var zoomValue = document.getElementById("customZoom").value;
  95.     if (pIsNumeric(zoomValue)){
  96.         var oImage = window.arguments[0];
  97.         pZoomImageAbs(oImage, zoomValue/100);
  98.     }
  99. }
  100.  
  101. function imagezoom_loadCustomZoom()
  102. {
  103.     var zoomValueBox = document.getElementById("customZoom");
  104.     var oImage = window.arguments[0];
  105.     zoomValueBox.value = oImage.zoomFactor;
  106. }
  107.  
  108. function imagezoom_customDim()
  109. {
  110.     var dimWidth = document.getElementById("dimWidth").value;
  111.     var dimHeight = document.getElementById("dimHeight").value;
  112.     if (pIsNumeric(dimWidth) && pIsNumeric(dimHeight)){
  113.         var oImage = window.arguments[0];
  114.         pSetDim(oImage, dimWidth, dimHeight, gDimAspect.checked);
  115.     }
  116. }
  117.  
  118. function imagezoom_loadCustomDim()
  119. {
  120.     gDimWidth = document.getElementById("dimWidth");
  121.     gDimHeight = document.getElementById("dimHeight");
  122.     gDimAspect = document.getElementById("dimAspect");
  123.     var oImage = window.arguments[0];
  124.     gDimWidth.value = oImage.width;
  125.     gDimHeight.value = oImage.height;
  126.     gDimRatio = oImage.width/oImage.height;
  127.     gDimAspect.checked = true;
  128. }